<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <h2>{{title}}</h2>
        <ul>
            <li v-for="item in student" :key="item">
                {{ item }}
            </li>
        </ul>
        <div><button @click="changeInfo">修改内容</button></div>
    </div>
    <!-- <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> -->
    <script src="../assets/vue3.js"></script>
    <script>
        const app = Vue.createApp({
            data() {
                return {
                    title: '欢迎光临~',
                    student: { id: 1, name: '张三', age: 32 },
                }
            },
            methods: {
                changeInfo() {
                    this.title = '网站已经被黑！';
                    this.student.name = '德行';
                    this.student.age = 32;
                }
            },
            watch: {
                title(newValue, oldValue) {
                    console.log(`【${oldValue}】被修改为：【${newValue}】`)
                },
                student(newValue, oldValue) {
                    console.log(newValue);
                }
            },
        });
        app.mount('#app');
    </script>
</body>

</html>